package com.zephyr.vchcenter.bpm.action;

import java.util.Date;

import org.apache.log4j.Logger;

import com.hiaward.bpm.action.TaskAction;
import com.hiaward.bpm.context.ServiceContext;
import com.hiaward.bpm.exception.ParameterException;
import com.hiaward.bpm.exception.ServiceException;
import com.zephyr.vchcenter.bean.Transfer;
import com.zephyr.vchcenter.bean.Voucher;
import com.zephyr.vchcenter.dao.IBaseDao;
import com.zephyr.vchcenter.helper.SpringHelper;

public class AuditAction extends TaskAction {
	private final Logger log=Logger.getLogger(AuditAction.class);
	@Override
	public void perform(ServiceContext arg0) throws ServiceException,
			ParameterException {
          log.debug("进入AuditAction............");
          String accno=(String)arg0.getInputParameterValue("accno");
          String amount=(String)arg0.getInputParameterValue("amount");
          String vchno=(String)arg0.getInputParameterValue("vchno");
          String vchtype=(String)arg0.getInputParameterValue("vchtype");
          String vchdate=(String)arg0.getInputParameterValue("vchdate");
          String vchsid=(String)arg0.getInputParameterValue("vchsid");
          String acctype=(String)arg0.getInputParameterValue("acctype");
          String rtreason=(String)arg0.getInputParameterValue("rtreason");
          log.debug(vchsid+"----");
          String vchpwd=(String)arg0.getInputParameterValue("vchpwd");
          String batno=(String)arg0.getInputParameterValue("batno");
          log.debug("batno"+batno);
          String auditResult=(String)arg0.getInputParameterValue("chkres");
          String verifyState=(String)arg0.getInputParameterValue("chkstate");
          log.debug(verifyState+"+++++++_____");
          IBaseDao dao=(IBaseDao)SpringHelper.getBean("baseDao");
          Voucher voucher=(Voucher)dao.findById("Voucher",vchsid);
          voucher.setRtreason(rtreason);
          voucher.setAccno(accno);
          voucher.setAmount(amount);
          voucher.setVchno(vchno);
          voucher.setVchdate(vchdate);
          voucher.setVchpwd(vchpwd);
          voucher.setBatno(batno);
          voucher.setPswdres("1");
          voucher.setChkclkno("黄兵");
          log.debug(acctype+"------>>--->>--->");
          if("2".equals(acctype)){
          log.debug("财政胡，将会转入财政户审票。。。。。。");
          //在这里需要调用外部接口查询财政户信息
          //voucher.setFinaid("1111");
         // voucher.setSigntype("零余额合并账户");
          voucher.setAcctype(acctype);    
          voucher.setChkstate("5");
          }
          voucher.setVchtype(vchtype);
          if(auditResult!=null){
        	  log.debug("审票结果不为空");
        	  voucher.setChkres(auditResult);
          }
          //Integer chkstate="0".equals(verifyState)?2:3;
          log.debug("审票状态"+verifyState);
          voucher.setChkstate(verifyState);
         // log.debug("----------->>----->>>-------->>>>>");
          dao.saveOrUpdate(voucher);
          //log.debug("---------------->>>-------->>>>>");
          //Date nowTime=new Date();
          //Long auditTime=nowTime.getTime();
          //arg0.setOutputParameterValue("auditTime", auditTime+"");
          log.debug("离开AuditAction............");
          
	}
	@Override
	public void serviceExceptionHandle(ServiceContext arg0,
			ServiceException arg1) {

	}

}
